{% extends "base_generic.html" %}

{% block extrahead %}
	<script type="text/javascript" src="/static/scripts/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
	<script type="text/javascript">
dojo.require("dojo.io.script");
dojo.require("dojo.parser");
dojo.require("dijit.form.InlineEditBox");
dojo.require("dijit.form.TextBox");
function updateTags(value) {
	dojo.xhrPost({
		url: "/admin/library/book/update-tags/",
		content: {isbn: "{{item.isbn}}", tags: value}
		}).addCallback(function(status) {
			console.debug(status);
		});
}
dojo.addOnLoad(function() {
	dojo.io.script.get({
		url: 'http://ecs.amazonaws.com/onca/xml',
		content: {
			Service: 'AWSECommerceService',
			SubscriptionId: '19267494ZR5A8E2CGPR2',
			AssociateTag: 'kokogiak7-20',
			Operation: 'ItemLookup',
			IdType: 'ISBN',
			SearchIndex: 'Books',
			ResponseGroup: 'Medium',
			ItemId: "{{item.isbn}}",
			Style: 'http://www.kunxi.org/files/learning-django-by-example/awsreview.xsl',
			ContentType: 'text/javascript',
		},
		callbackParamName: "CallBack",
		}).addCallback(function(desc) {
			dojo.byId("review").innerHTML =  desc;
			dojo.byId("review-title").style.display = "";
		});
});
</script>
{% endblock %}

{% block content %}
<div class="detail">
	<dl>
		<dt><img src="{{ item.get_cover_url}}" align="left"/></dt>
		<dd>
			<h2><a href="/library/book/{{ item.isbn }}">{{ item.title }}</a></h3>
			<p>by {{ item.authors.all|join:", "}}</p>
			<p>Publisher: {{ item.publisher }}</p>
			<p>Pub Date: {{ item.pub_date }}</p>
			<p>ISBN-10: {{ item.isbn }} </p>
			<p>Pages: {{ item.pages }} </p>
		</dd>
	</dl>
	<br clear="all"/>

	Tags: <span id="editable" dojoType="dijit.form.InlineEditBox" autoSave="true" onChange="updateTags(arguments[0])">
		<input dojoType="dijit.form.TextBox" 
		{% if tags %} 
			value='{{ tags|join:", "}}'
		{% else %}
			value='None'
		{%endif%}/>
	</span>
	<h2 id="review-title" style="display: none">Editorial Reviews</h2>
	<div id="review">
	</div>
</div>
{% endblock %}

